//disabled @Test rule for JUnit tests 
//$codepro.audit.disable disallowTestAnnotation
/**
 * JUnit tests
 */
package docoffice.test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import org.junit.Before;
import org.junit.Test;

import docoffice.doss.Appointment;
import docoffice.doss.Authentication;
import docoffice.doss.BloodPressure;
import docoffice.doss.BodyTemp;
import docoffice.doss.DocOrders;
import docoffice.doss.Doctor;
import docoffice.doss.Height;
import docoffice.doss.Invoice;
import docoffice.doss.LabWork;
import docoffice.doss.MedicalEmployee;
import docoffice.doss.Patient;
import docoffice.doss.Patient.insuranceCarrier;
import docoffice.doss.Prescription;
import docoffice.doss.SysAdmin;
import docoffice.doss.TreatmentRec;
import docoffice.doss.Vitals;
import docoffice.doss.Weight;

/**
 * @author Ray Nosari
 * @version Revision $1.0
 */
public class RayCompleteTestsII{
	/**
	 * Field authenticator.
	 */
	private Authentication authenticator;
	
	/**
	 * Field patient.
	 */
	private Patient patient;
	
	/**
	 * Field nurse.
	 */
	private MedicalEmployee nurse;
	
	/**
	 * Field doctor.
	 */
	private Doctor doctor;
	
	/**
	 * Field admin.
	 */
	private SysAdmin admin;
	
	/**
	 * Field appointment.
	 */
	private Appointment appointment;

	/**
	 * Field treatment.
	 */
	private TreatmentRec treatment;
	
	/**
	 * Field orders.
	 */
	private DocOrders orders;
	
	/**
	 * Field prescription.
	 */
	private Prescription prescription;
	
	/**
	 * Field labwork.
	 */
	private LabWork labwork;
	
	/**
	 * Field vitals.
	 */
	private Vitals vitals;
	
	/**
	 * Field height.
	 */
	private Height height;
	
	/**
	 * Field weight.
	 */
	private Weight weight;
	
	/**
	 * Field bloodPressure.
	 */
	private BloodPressure bloodPressure;
	
	/**
	 * Field temperature.
	 */
	private BodyTemp temperature;
	
	/**
	 * Field invoice.
	 */
	private Invoice invoice;
	
	/**
	 * Field PULSE.
	 * (value is 80)
	 */
	private static final int PULSE = 80;
	
	/**
	 * Field FEET.
	 * (value is 6)
	 */
	private static final int FEET = 6;
	
	/**
	 * Field INCHES.
	 * (value is 2)
	 */
	private static final int INCHES = 2;
	
	/**
	 * Field SYSTOLIC.
	 * (value is 120)
	 */
	private static final int SYSTOLIC = 120;
	
	/**
	 * Field DIASTOLIC.
	 * (value is 80)
	 */
	private static final int DIASTOLIC = 80;
	
	/**
	 * Field WEIGHT.
	 * (value is 200)
	 */
	private static final int WEIGHT = 200;
	
	/**
	 * Field BODYTEMPERATURE.
	 * (value is 98.6)
	 */
	private static final double BODYTEMPERATURE = 98.6;
	
	/**
	 * Field EXPERIENCE.
	 * (value is 15)
	 */
	private static final int EXPERIENCE = 15;
	
	/**
	 * Method initialize.
	 */
	@Before
	public void initialize(){
		//Authenticate
		authenticator = new Authentication();
		
		//User Stuff
		patient = new Patient("Rock Star");
		patient.setAddress("124 Fake St. Atlanta, GA 30332");
		patient.setAge(26);
		patient.setAllergies("Pollen");
		patient.setEmail("rock.star@gmail.com");
		patient.setGender("Male");
		patient.setInsuranceCarrier(insuranceCarrier.BEST);
		patient.setPhone("404-345-2623");
		patient.setUsername("rockstar");
		patient.setPassword("teamrockstar");
		
		nurse = new MedicalEmployee("Nurse Carla", "Nurse");
		nurse.setYearsExperience(EXPERIENCE);
		nurse.setUsername("carla");
		nurse.setPassword("turkleton");
		
		doctor = new Doctor("Dr. Blah", "stuff");
		doctor.setUsername("blah");
		doctor.setPassword("drblah");
		
		admin = new SysAdmin("Wade Wilson");
		admin.setUsername("deadpool");
		admin.setPassword("mercenary");
		
		//Vitals stuff
		height = new Height(PULSE, FEET, INCHES);
		bloodPressure = new BloodPressure(PULSE, SYSTOLIC, DIASTOLIC);
		weight = new Weight(PULSE, WEIGHT);
		temperature = new BodyTemp(PULSE, BODYTEMPERATURE);
		vitals = new Vitals(PULSE, height, temperature, weight, bloodPressure);
		
		//DocOrders stuff
		labwork = new LabWork("X-ray", 50);
		prescription = new Prescription("Morphine", "Take a bunch");
		orders = new DocOrders(prescription, labwork, "Take it easy.");
		
		//Appointment stuff
		treatment = new TreatmentRec(doctor, "4/30/2011", "11:00 AM", 
				"Swollen ankle", "Sprained ankle", orders, nurse, vitals);
		appointment = new Appointment("4/30/2011", "11:00 AM", "Swelling", 
				doctor);
		appointment.setPatient(patient);
		appointment.setTreatment(treatment);
		
		//Invoice stuff
		invoice = new Invoice(appointment);
	}
	
	/**
	 * Method testCreateUser.
	 */
	@Test
	public void testCreateUser(){
		patient.createUser();
	}
	
	/**
	 * Method testCreatePatient.
	 */
	@Test
	public void testCreatePatient(){
		patient.createPatient();
	}
	
	/**
	 * Method testUpdatePatient.
	 */
	@Test
	public void testUpdatePatient(){
		patient.setName("Rawk Star");
		patient.updatePatient();
	}
	
	/**
	 * Method testReadPatient.
	 */
	@Test
	public void testReadPatient(){
		final int id = patient.readPatientID();
		patient.setId(id);
		patient = patient.readPatient();
		assertNotNull("Patient read correctly from database", patient);
	}
	
	/**
	 * Method testLookupPatient.
	 */
	@Test
	public void testLookupPatient(){
		final String username = "rockstar";
		Patient newPatient = new Patient("");
		newPatient = newPatient.lookupPatient(username);
		assertNotNull("Patient lookup works correctly", newPatient);
	}
	
	/**
	 * Method testCreateMedicalEmployee.
	 */
	@Test
	public void testCreateMedicalEmployee(){
		nurse.createUser();
		nurse.createMedicalEmployee();
	}
	
	/**
	 * Method testUpdateMedicalEmployee.
	 */
	@Test
	public void testUpdateMedicalEmployee(){
		nurse.setName("Mildred Rockstar");
		nurse.updateMedicalEmployee();
		nurse = nurse.readMedicalEmployee();
		assertNotNull("Medical Employee read and updated correctly", nurse);
	}
	
	/**
	 * Method testCreateDoctor.
	 */
	@Test
	public void testCreateDoctor(){
		doctor.createUser();
		doctor.createMedicalEmployee();
		doctor.setEmployeeType("Doctor");
		doctor.setYearsExperience(30);
		doctor.updateMedicalEmployee();
		doctor.createDoctor();
	}
	
	/**
	 * Method testUpdateDoctor.
	 */
	@Test
	public void testUpdateDoctor(){
		final String newSpecialty = "Orthopedics";
		final int id = doctor.readMedicalEmployeeID();
		doctor.setId(id);
		doctor.setSpecialty(newSpecialty);
		doctor.updateDoctor();
		doctor = doctor.readDoctor();
		assertNotNull("Doctor updated/read successfully", doctor);
	}
	
	/**
	 * Method testCreateMedicalEmployeeSysAdmin.
	 */
	@Test
	public void testCreateMedicalEmployeeSysAdmin(){
		admin.createUser();
		admin.createMedicalEmployee();
	}
	
	/**
	 * Method testUpdateMedicalEmployeeSysAdmin.
	 */
	@Test
	public void testUpdateMedicalEmployeeSysAdmin(){
		final int id = admin.readMedicalEmployeeID();
		admin.setId(id);
		admin.setName("Wade Rockstar");
		admin.updateMedicalEmployee();
		admin.setYearsExperience(EXPERIENCE);
		assertNotNull("System Admin read and updated correctly", admin);
	}
	
	/**
	 * Method testCreateTreatmentRec.
	 */
	@Test
	public void testCreateTreatmentRec(){
		final int docid = doctor.readMedicalEmployeeID();
		doctor.setId(docid);
		final int nurseid = nurse.readMedicalEmployeeID();
		nurse.setId(nurseid);
		final int ordersid = orders.readDocOrdersId(orders);
		orders.setId(ordersid);
		final int vitalsid = vitals.readVitalsID(vitals);
		vitals.setId(vitalsid);
		treatment.createTreatmentRec(doctor, "4/30/2011", "11:00 AM", "Swollen ankle", "Sprained ankle", orders, nurse, vitals);
	}
	
	/**
	 * Method testCreateAppointment.
	 */
	@Test
	public void testCreateAppointment(){
		final int docid = doctor.readMedicalEmployeeID();
		doctor.setId(docid);
		final int patientid = patient.readPatientID();
		patient.setId(patientid);
		final int treatmentid = treatment.readTreatmentRecId(treatment);
		treatment.setId(treatmentid);
		appointment.createAppointment("4/30/2011", "11:00 AM", "Swelling", doctor, patient, treatment);
		final int appointmentid = appointment.readAppointmentId(appointment);
		appointment.setId(appointmentid);
	}
	
	/**
	 * Method testCreateInvoice
	 */
	@Test
	public void testCreateInvoice(){
		invoice.createInvoice();
	}
	
	/**
	 * Method testblahhhh
	 */
	public void testUpdateInvoice(){
		Appointment appt = appointment;
		appt.setReason("NEW REASON!");
		final int docid = doctor.readMedicalEmployeeID();
		doctor.setId(docid);
		final int patientid = patient.readPatientID();
		patient.setId(patientid);
		final int treatmentid = treatment.readTreatmentRecId(treatment);
		treatment.setId(treatmentid);
		appt.createAppointment("4/30/2011", "11:00 AM", "Swelling", doctor, patient, treatment);
		final int appointmentid = appt.readAppointmentId(appt);
		appt.setId(appointmentid);
		invoice.updateInvoice();
	}
}
